﻿
using Base.ClientUI;
using System;
using System.Windows.Forms;
 namespace Base.ClientUI {
    public partial class LogFrms : UITitlePage
    {
        public LogFrms()
        {
            InitializeComponent();
            uiDataGridView1.AddColumn("消息", "Msg").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            uiDataGridView1.AddColumn("时间", "timeTicks").AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            uiDataGridView1.ReadOnly = true;
  
         }
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x02000000; // 用双缓冲绘制窗口的所有子控件
                return cp;
            }
        }
        public override void Init()
        {
            base.Init();
            PageGridSource();
        }
   
     
        private bool PageGridSource()
        {
            var list = HttpSysUtil.showLog();
            if (list == null)
            {
                this.ShowErrorTip("网络不稳定!");
                return false;
                ;
            }
             uiDataGridView1.DataSource = list;
            return true;
         }
    
         private void uiDataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (uiDataGridView1 == null || uiDataGridView1.Rows.Count == 0)
            {
                return;
            }
            String name = uiDataGridView1.Columns[e.ColumnIndex].DataPropertyName;
            if ("timeTicks1" == name)
            {
                long value = (long)e.Value;
                 DateTime dt = new DateTime(value);
                e.Value = dt;
            }
        }
      
        private void uiDataGridView1_MouseUp(object sender ,MouseEventArgs e) {
            if( e.Button == MouseButtons.Right ) {
                if( PageGridSource() ) {
                    this.ShowInfoTip("已加载！");
                }
            }
        }
    }
}